# Script to invoke EmSenseAPI/Download

import json, urllib2, random, time, math

# Make 10 download requests for sensorIDs from 1 to 10 for the past 5 hours

for reqCount in xrange(1,10):					# takes IDs from 1 - 10
	snrID = reqCount
	stime = math.floor(time.time()) - 5*60*60	# 5 hours ago
	etime = math.floor(time.time())				# current time
	downloadData = {
					"sensorID" : snrID,
					"startTime": stime,
					"endTime":  etime
	}

	dreq = urllib2.Request('http://localhost:9000/emsense/download')
	dreq.add_header('Content-Type', 'application/json')

	response = urllib2.urlopen(dreq, json.dumps(downloadData))
	print json.dumps(response.read(), sort_keys=True, indent=4)
	print
